import Cookie from "@/utils/cookie";
import axios from "axios";
import windowConst from "@/utils/const";
// 创建实例
const http = axios.create({
  //设置基准地址
  baseURL: windowConst.VUE_APP_API_HOST,
  //请求超时设置，单位ms
  timeout: 2000,
  headers: {
    aitalk_token: Cookie.getCookie("aitalk_token") || "",
  },
});
// request 请求拦截器
http.interceptors.request.use(
  (config) => {
    return config;
  },
  (error) => {
    return Promise.reject(error);
  },
);

// response响应拦截器
http.interceptors.response.use(
  (response) => {
    return response.data;
  },
  (error) => {
    return Promise.reject(error);
  },
);

export default http;
